package com.example.demo;

import javafx.application.Application;
import javafx.application.HostServices;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.TextField;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Pane;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
import java.text.SimpleDateFormat;

import java.util.Date;
import java.util.Timer;
import java.util.TimerTask;


public class Images extends Application {
    public Label TimeHour;
    public Label TimeMin;
    public Label TimeSec;
    public HBox hBoxTime;
    public ImageView imageView;
    public Pane root;
    public HBox hBox;
    public HBox hBoxSexImage;
    public HBox hBoxImageExr;
    public HBox hBoxName;
    public HBox hBoxLove;
    public HBox hBoxLoveIamge;
    public HBox gethBoxChoiceLoveImg;
    public VBox allInfoBox;
    public HBox hBoxPhoto;
    public HBox hBoxPhotoImage;
    public HBox hBoxChoiceMalePho;
    public HBox hBoxPhone;
    public HBox hBoxPhoneSecond;
    public HBox hBoxEmail;
    public Timer timer;
    public Label rePho;
    public HBox PhotoSecondImage;

    @Override
    public void start(Stage primaryStage) throws Exception {
        rePho=new Label("最近收藏");
        PhotoSecondImage=new HBox();
        PhotoSecondImage.setId("PhotoSecondImage");
        PhotoSecondImage.getChildren().add(rePho);
        hBoxPhoneSecond=new HBox();
        hBoxPhoneSecond.setId("hBoxPhoneSecond");
        hBoxEmail=new HBox();
        hBoxEmail.setId("hBoxEmail");
        hBoxPhotoImage=new HBox();
        hBoxPhotoImage.setId("hBoxPhotoImage");
        gethBoxChoiceLoveImg=new HBox();
        hBoxLoveIamge=new HBox();
        hBoxLoveIamge.setId("hBoxLoveImage");
        gethBoxChoiceLoveImg.setId("gethBoxChoiceLoveImg");
        hBoxPhone=new HBox();
        hBoxPhone.setId("hBoxPhone");
        hBoxChoiceMalePho=new HBox();
        root= new Pane();
        hBoxSexImage=new HBox();
        hBoxSexImage.setId("hBoxSexImage");
        hBoxImageExr=new HBox();
        hBoxImageExr.setId("hBoxImageExr");
        hBoxName=new HBox();
        hBoxName.setId("hBoxName");
        hBox=new HBox();
        allInfoBox=new VBox();
        hBoxPhoto=new HBox();
        hBoxLove=new HBox();
        hBoxTime=new HBox();
        Scene scene=new Scene(root,420,480);
        primaryStage.setTitle("FONT & IMAGES");

        //引用css文件
        HostServices host = this.getHostServices();
        String css = host.resolveURI(host.getDocumentBase(),"src/main/java/com/example/demo/css/Images.css");
        scene.getStylesheets().add(css);


        init(root);
        primaryStage.setScene(scene);
        primaryStage.show();
    }

    public void initImage(Image image,double preX,double preY)
    {
//        System.out.println(image.getUrl());

        imageView = new ImageView();
        imageView.setImage(image);
        if(image.getUrl().equals("file:src/main/java/com/example/demo/images/Excer.png")||image.getUrl().equals("file:src/main/java/com/example/demo/images/running.png")||image.getUrl().equals("file:src/main/java/com/example/demo/images/badmiton.png")||image.getUrl().equals("file:src/main/java/com/example/demo/images/swimming.png")||image.getUrl().equals("file:src/main/java/com/example/demo/images/arrow.png"))
        {
            hBoxImageExr.getChildren().add(imageView);
        }
        else if(image.getUrl().equals("file:src/main/java/com/example/demo/images/sex.png"))
        {
            hBoxSexImage.getChildren().add(imageView);
        }
        else if(image.getUrl().equals("file:src/main/java/com/example/demo/images/nvshenfirst.jpg")||image.getUrl().equals("file:src/main/java/com/example/demo/images/nvshenthird.jpg"))
        {
            PhotoSecondImage.getChildren().add(imageView);
        }
        else if(image.getUrl().equals("file:src/main/java/com/example/demo/images/photography.png")){
            hBoxPhotoImage.getChildren().add(imageView);
        }
//        else if(image.getUrl().equals("file:src/main/java/com/example/demo/images/webPictureg.png"))
//        {
//            System.out.println("hahha");
//            gethBoxChoiceLoveImg.getChildren().add(imageView);
//        }
        else if(image.getUrl().equals("file:src/main/java/com/example/demo/images/name.png"))
        {
            hBoxName.getChildren().add(imageView);
        }
//        else if(image.getUrl().equals("file:src/main/java/com/example/demo/images/webPicturex.png"))
//        {
//            hBoxSexImage.getChildren().add(imageView);
//        }
        else if(image.getUrl().equals("file:src/main/java/com/example/demo/images/profession.png")||image.getUrl().equals("file:src/main/java/com/example/demo/images/malefirst.png")||image.getUrl().equals("")||image.getUrl().equals("file:src/main/java/com/example/demo/images/elder.png"))
        {
            hBoxChoiceMalePho.getChildren().add(imageView);
        }
        else if(image.getUrl().equals("file:src/main/java/com/example/demo/images/phone.png")){
            hBoxPhone.getChildren().add(imageView);
        }
        else if(image.getUrl().equals("file:src/main/java/com/example/demo/images/email.png"))
        {
            hBoxEmail.getChildren().add(imageView);
        }
        else if(image.getUrl().equals("file:src/main/java/com/example/demo/images/phoneSecond.png"))
        {
            hBoxPhoneSecond.getChildren().add(imageView);
        }
        else
        {
            imageView.setLayoutX(preX);
            imageView.setLayoutY(preY);
            root.getChildren().add(imageView);
        }

    }

    public void init(Pane root)
    {

        TimeHour=new Label();
        TimeSec=new Label();
        TimeMin=new Label();

        Label phoneLabelSecond=new Label("3214343");
        Label labelEmail=new Label("2310064088@qq.com");
        Label phoneLabel=new Label("2318439");
        phoneLabel.setId("phoneLabel");
        hBox.setPadding(new Insets(10));//会使得按钮距离父控件的边缘为20，上下左右都会，再小的父控件都会撑大
        hBox.setSpacing(5);
        hBox.setLayoutX(0);
        hBox.setLayoutY(100);
        hBoxName.setLayoutY(0);
        hBoxPhoto.setLayoutY(180);
        hBoxLoveIamge=new HBox();
        hBoxSexImage.setId("hBoxSexImage");
        hBoxChoiceMalePho.setId("hBoxChoiceMalePho");
//        hBox.setAlignment(Pos.BOTTOM_CENTER);
        Button botton=new Button();
//        botton.setLayoutX(20);
//        botton.setText("请点击我");

//        Image imageSetting =new Image("file:src/main/java/com/example/demo/images/732606.png",20.0,20.0,true,true);
//        Image imageClock =new Image("file:src/main/java/com/example/demo/images/clockin.png",40.0,40.0,true,true);
        Image imageElsePhoPro=new Image("file:src/main/java/com/example/demo/images/profession.png",60.0,60.0,true,true);
        System.out.println("URL"+imageElsePhoPro.getUrl());
        Image imageElsePhoMaleFirst=new Image("file:src/main/java/com/example/demo/images/malefirst.png",60.0,60.0,true,true);
        Image imageElsePhoElder=new Image("file:src/main/java/com/example/demo/images/elder.png",60.0,60.0,true,true);
        Image imagePhone=new Image("file:src/main/java/com/example/demo/images/phone.png",40.0,40.0,true,true);
        Image imageEmail=new Image("file:src/main/java/com/example/demo/images/email.png",40.0,40.0,true,true);
        Image imageLoveFirst=new Image("file:src/main/java/com/example/demo/images/loveg.png",40.0,40.0,true,true);
        Image imagephoneSecond=new Image("file:src/main/java/com/example/demo/images/phoneSecond.png",60.0,60.0,true,true);
        initImage(imagephoneSecond,0,0);
        hBoxPhoneSecond.getChildren().add(phoneLabelSecond);

        Image imageWallet=new Image("file:src/main/java/com/example/demo/images/wallet.png",20.0,20.0,true,true);
        initImage(imageWallet,0.0,60.0);
        Label label=new Label("我的钱包");
        Label nameLabel=new Label("姓名");
        Label nameTextField=new Label("林林ε=(´ο｀*)))");
        nameTextField.setId("nameLabel");
        Image imagesex=new Image("file:src/main/java/com/example/demo/images/sex.png",40.0,40.0,true,true);
        Label sexLabel=new Label("male");
        sexLabel.setId("sexLabel");
//        hBoxName.getChildren().add(nameLabel);
        hBoxName.setId("hBoxName");
        Image nameImage=new Image("file:src/main/java/com/example/demo/images/name.png",40.0,40.0,true,true);
        Image imageLoveHouse=new Image("file:src/main/java/com/example/demo/images/lovehouse.png",60.0,60.0,true,true);
        Label labelLove=new Label("我的情侣空间❥(^_-)");
        hBoxLove.getChildren().add(labelLove);
//        initImage(imageLoveHouse,0.0,0.0);

        Label Exer=new Label("今日份运动");
        Exer.setId("Exercise");
        Exer.setLayoutX(0);
        Exer.setLayoutY(110);
        hBox.getChildren().add(Exer);

        Image imagePhoto=new Image("file:src/main/java/com/example/demo/images/photography.png",60.0,60.0,true,true);
        Image imageExer=new Image("file:src/main/java/com/example/demo/images/Excer.png",60.0,60.0,true,true);
        Image imageRunning =new Image("file:src/main/java/com/example/demo/images/running.png",60.0,60.0,true,true);
        Image imageBadmoton =new Image("file:src/main/java/com/example/demo/images/badmiton.png",60.0,60.0,true,true);
        Image imageswimming =new Image("file:src/main/java/com/example/demo/images/swimming.png",60.0,60.0,true,true);
        Image imageArrow=new Image("file:src/main/java/com/example/demo/images/arrow.png",60.0,60.0,true,true);
        Image ImagePhotoelsefirst=new Image("file:src/main/java/com/example/demo/images/nvshenfirst.jpg",80,60,true,true);
//        Image imageWallet=new Image("file:E:\\webPicture\\wallet.png",20.0,20.0,true,true);
        Image ImagePhotoelseSecond=new Image("file:src/main/java/com/example/demo/images/nvshenthird.jpg",80,60,true,true);
        initImage(nameImage,0,0);
        initImage(ImagePhotoelsefirst,0,0);
        initImage(ImagePhotoelseSecond,0,0);

        hBoxName.getChildren().add(nameTextField);
        //有一个先后次序
        initImage(imagesex,0,0);
        hBoxSexImage.getChildren().add(sexLabel);
//        hBoxName.getChildren().addAll(sexLabel)
        initImage(imageLoveFirst,0,0);
        initImage(imageEmail,0,0);
        initImage(imageElsePhoPro,0,0);
        initImage(imageElsePhoMaleFirst,0,0);
        initImage(imageElsePhoElder,0,0);
        initImage(imagePhone,0,0);
        hBoxPhone.getChildren().add(phoneLabel);
        initImage(imageArrow,230,110);
        initImage(imageRunning,50,110);
        initImage(imageBadmoton,110,110);
        initImage(imageswimming,150,110);
        Label photo=new Label("相册");
        hBoxPhoto.getChildren().add(photo);
        initImage(imagePhoto,0,0);
        initImage(imageExer,0,110);
//        initImage(imageSetting,0.0,20.0);
//        initImage(imageClock,0.0,40);
        Label labelClock=new Label("今天还没打卡哦");
        labelClock.setId("clockLabel");
        labelClock.setLayoutX(50);
        labelClock.setLayoutY(20);
        Label personality=new Label("设置");
        personality.setLayoutX(200);
        personality.setId("individal");
        Label UsualLabel=new Label("通用");
        UsualLabel.setId("usualLabel");
        UsualLabel.setLayoutX(20);
        UsualLabel.setLayoutY(40);
        Label mode=new Label("夜间模式");
        mode.setLayoutY(80);
        mode.setLayoutX(20);
        mode.setId("mode");
        TextField textField=new TextField();
//        hBoxTime.getChildren().addAll(TimeHour,TimeMin,TimeSec);
        hBoxPhone.getChildren().add(hBoxPhoneSecond);
        hBoxSexImage.getChildren().add(hBoxChoiceMalePho);
        hBoxEmail.getChildren().add(labelEmail);
//        hBoxLoveIamge.getChildren().add(gethBoxChoiceLoveImg);
        hBoxLoveIamge.getChildren().add(gethBoxChoiceLoveImg);
        hBoxPhotoImage.getChildren().add(PhotoSecondImage);
        allInfoBox.getChildren().add(hBoxName);
        allInfoBox.getChildren().add(hBoxPhone);
        allInfoBox.getChildren().add(hBoxEmail);
        allInfoBox.setSpacing(5);
        allInfoBox.getChildren().add(hBoxSexImage);
        allInfoBox.getChildren().add(hBox);
        allInfoBox.getChildren().add(hBoxImageExr);
//        allInfoBox.getChildren().add(hBoxLove);
//        allInfoBox.getChildren().add(hBoxLoveIamge);
        allInfoBox.getChildren().add(hBoxPhoto);
        allInfoBox.getChildren().add(hBoxPhotoImage);

//        allInfoBox.getChildren().add(hBoxTime);
        root.getChildren().add(allInfoBox);
//        botton.setText("小刀");
//        root.getChildren().add(hBox);
//        root.getChildren().addAll(labelClock,personality,UsualLabel,mode);

    }

    public static void main(String[] args) {
        launch();
    }
}

